<?php
error_reporting("E_ALL^E_NOTICE");
session_start();
include './function/Pengguna.php';
include './function/Tampil.php';
$tampil = new Tampil();
$pengguna = new Pengguna();
?>
<html>
    <head>
        <meta name="key/words" content="berbagi,charity,community"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/bootstrap.css">
        <link rel="stylesheet" href="style.css">
        <title>Semua Berbagi - Indonesia Charity Community</title>
        <script type="text/javascript" src="js/autocomplete.js"></script>
        <script type="text/javascript" src="js/jquery.min.js"></script>
    </head>
    <body>
        <?php
        if (isset($_SESSION['user'])) {
            $status = $_SESSION['user']['status'];
        } else {
            include './masuk.php';
            exit();
        }
        if (isset($_SESSION['uploadbarang'])) {
            $kabupaten = $_SESSION['uploadbarang']['kabupaten'];
            $alamat = $_SESSION['uploadbarang']['alamat'];
            $telepon = $_SESSION['uploadbarang']['telepon'];
            $kategori = $_SESSION['uploadbarang']['kategori'];
            $namabarang = $_SESSION['uploadbarang']['namabarang'];
            $deskripsi = $_SESSION['uploadbarang']['deskripsi'];
            $gambar = $_SESSION['uploadbarang']['gambar'];
            $statusupload = $_SESSION['uploadbarang']['statusupload'];
            echo '<script>alert("' . $kabupaten . '\n' . $alamat . '\n' . $telepon . '\n' . $kategori . '\n' . $namabarang . '\n' . $deskripsi . '\n'
            . $gambar . '\n' . $statusupload . '")</script>';
            unset($_SESSION['uploadbarang']);
        }
        ?>
        <div class="container">
            <div class="navbar navbar-default" role="navigation">
                <div class="container-fluid">
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed togle_margin" data-toggle="collapse" data-target=".navbar-collapse"> 
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span> 
                            <span class="icon-bar"></span> 
                            <span class="icon-bar"></span> 
                        </button> 
                        <form class="navbar-form" role="search">
                            <div class="input-group">
                                <input type="text" class="form-control" placeholder="Search" name="text_search">
                                <div class="input-group-btn">
                                    <button class="btn btn-default buttonCari" type="submit" name="button_search"><i class="glyphicon glyphicon-search"></i></button>
                                </div>
                            </div>
                        </form>
                    </div> 
                    <div class="navbar-collapse collapse"> 
                        <ul class="nav navbar-nav navbar-right"> 
                            <li>
                                <a href="pageUser.php">Beranda</a>
                            </li>
                            <li>
                                <a href="clearsession.php">Logout</a>
                            </li> 
                        </ul>                        
                        <div class="navbar-text navbar-right">Masuk sebagai <?php echo $status ?>     |</div>
                    </div> 
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="row">
                        <form action="action_uploadBarang.php" method="POST" enctype="multipart/form-data">
                            <div class="col-md-6 col-xs-12">
                                <img src="img/logo.png" class="img-responsive im"/>
                                <label style="font-size: 25px">
                                    Share barang pilih Anda untuk mereka yang membutuhkan...  
                                </label> 
                                </br>
                                </br>
                                <label style="font-size: 15px;color: red">
                                    Langkah 1 : Isikan data Anda...  
                                </label>
                                </br>
                                <?php
                                if ($pengguna->cekKabupatenPengguna($status) == 'belum') {
                                    ?>
                                    <label>Kabupaten : </label>
                                    <input type="text" class="form-control" name="kabupaten" id="kab" onkeyup="autocomplet()"/>
                                    <ul id="kab_list" class="list-unstyled kab_list"></ul>
                                    </br>
                                    <?php
                                } else {
                                    ?>
                                    <label>Kabupaten : </label>
                                    <input type="text" class="form-control" value="<?php echo $pengguna->tampilKabupatenPengguna($status) ?>" name="kabupaten" id="kab" onkeyup="autocomplet()"/>
                                    <ul id="kab_list" class="list-unstyled kab_list"></ul>
                                    </br>
                                    <?php
                                }
                                if ($pengguna->tampilAlamatPengguna($status) == '') {
                                    ?>
                                    <input type = "text" class="form-control" placeholder="Alamat *" name="alamat"/>
                                    </br>
                                    <?php
                                } else {
                                    ?>
                                    <input type = "text" class="form-control" value = "<?php echo $pengguna->tampilAlamatPengguna($status) ?>" name = "alamat"/>
                                    </br>
                                    <?php
                                }
                                if ($pengguna->tampiltelpPengguna($status) == '') {
                                    ?>
                                    <input type = "text" class="form-control" placeholder="Telepon *" name="telepon"/>
                                    </br>
                                    <?php
                                } else {
                                    ?>
                                    <input type = "text" class="form-control" value = "<?php echo $pengguna->tampiltelpPengguna($status) ?>" name = "telepon"/>
                                    </br>
                                    <?php
                                }
                                ?>
                                </br>
                            </div>
                            <div class="col-md-6 col-xs-12">
                                <label style="font-size: 15px;color: red">
                                    Langkah 2 : Isikan data barang...  
                                </label> 
                                </br>
                                <select class="form-control" name="kategori">
                                    <option>Kategori *</option>
                                    <?php
                                    $row = 0;
                                    while ($row < sizeof($tampil->tampilKategori())) {
                                        echo '<option value = ' . $tampil->tampilIdKategori()[$row] . '>' . $tampil->tampilKategori()[$row] . '</option>';
                                        $row++;
                                    }
                                    ?>
                                </select></br> 
                                <input type="text" class="form-control" placeholder="Nama barang *" name="namaBarang"/>
                                </br>
                                <textarea class="form-control" rows="6" placeholder="Alasan anda memberikan barang ini *" name="deskripsi"></textarea>
                                </br>
                                <label for="inputGambar">Upload gambar :</label>
                                </br>
                                <label>Gambar 1 (default)</label><input type="file" name="uploadFile"/>
                                </br>
                                <label>Gambar 2</label><input type="file" name="uploadFile2"/>
                                </br>
                                <label>Gambar 3</label><input type="file" name="uploadFile3"/>
                                </br>
                                <input type="submit" class="btn btn-primary" value="UPLOAD" name="upload"/>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

            <div class="panel panel-default panelKat">
                <div class="panel-footer panelKaki">
                    <div class="row">
                        <div class="col-md-12 col-xs-12">
                            <br><br><br>
                            <center><label class="fontKaki"><h4>@ Copyright 2014 semua berbagi - All right reserved</h4></label></center>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>
